package com.example.demo.server3.template;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class CMPP_CONNECT_RESP implements ProtocolTemplate {
    private MessageHeader messageHeader;
    private byte Status;
    private String AuthenticatorISMG;
    private byte Version;

    @Override
    public void structure(ByteBuf buf) {

    }

    public ByteBuf destruct(){
        ByteBuf superByteBuf = messageHeader.destruct();
        ByteBuf byteBuf = Unpooled.buffer(18);
        ByteBuf byteBufAll = Unpooled.buffer(30);
        byteBuf.writeByte(Status);
        byteBuf.writeBytes(AuthenticatorISMG.getBytes());//这里需要考虑字符集的问题
        byteBuf.writeByte(Version);
        byteBufAll.writeBytes(superByteBuf);
        byteBufAll.writeBytes(byteBuf);
        return byteBufAll;
    }

    public MessageHeader getMessageHeader() {
        return messageHeader;
    }

    public void setMessageHeader(MessageHeader messageHeader) {
        this.messageHeader = messageHeader;
    }

    public byte getStatus() {
        return Status;
    }

    public void setStatus(byte status) {
        Status = status;
    }

    public String getAuthenticatorISMG() {
        return AuthenticatorISMG;
    }

    public void setAuthenticatorISMG(String authenticatorISMG) {
        AuthenticatorISMG = authenticatorISMG;
    }

    public byte getVersion() {
        return Version;
    }

    public void setVersion(byte version) {
        Version = version;
    }
}
